package sip

import (
	"encoding/xml"
	"fmt"

	"gitee.com/larry_wan/go-lib/etree"
)

type PTZInfo struct {
	PresetID   string
	PresetName string
}

func UnmarshalPTZInfo(e *etree.Element) (rec *PTZInfo, err error) {
	if e == nil {
		err = fmt.Errorf("xml not found")
		return
	}
	doc := etree.NewDocument()
	doc.SetRoot(e)
	doc.Indent(4)
	xmlStr, err := doc.WriteToString()
	if err != nil {
		return
	}
	_rec := &PTZInfo{}
	err = xml.Unmarshal([]byte(xmlStr), _rec)
	if err != nil {
		return
	}
	rec = _rec
	return
}
